//
//  MusicTool.m
//  QQMusic
//
//  Created by wwj on 16/4/21.
//  Copyright © 2016年 wwj. All rights reserved.
//

#import "MusicTool.h"
#import "XMGMusic.h"
#import "MJExtension.h"

@interface MusicTool ()

@end

static NSArray *_musics;
static XMGMusic *_currentMusic;

@implementation MusicTool

+ (void)initialize{
    _musics = [XMGMusic objectArrayWithFilename:@"Musics.plist"];
    _currentMusic = _musics.firstObject;
}

+ (NSArray *)getMusics{
    return _musics;
}

+ (XMGMusic *)currentMusic{
    return _currentMusic;
}

+ (XMGMusic *)nextMusic{
    NSInteger current = [_musics indexOfObject:_currentMusic];
    NSInteger next = ++current;
    if (next > _musics.count - 1) {
        next = 0;
    }
    return _musics[next];
}

+ (XMGMusic *)preMusic{
    NSInteger current = [_musics indexOfObject:_currentMusic];
    NSInteger next = --current;
    if (next < 0) {
        next = _musics.count - 1;
    }
    return _musics[next];
}

+ (void)setPlayMusic:(XMGMusic *)music{
    _currentMusic = music;
}
@end
